package com.stu.exercise.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface StatisticMapper {

    @Select("select c.`name`, sum(o.total_price) price  from customer c, orders o where c.id = o.user_id group by c.id")
    List<Map<String,Object>> getOrderStatistic();

    @Select("select u.`name`, sum(s.price) price from `user` u, shopping s where u.id = s.user_id group by u.id")
    List<Map<String,Object>> getShopStatistic();

    @Select("select e.`name`, sum(o.total_price) price from equipment e, orders o where e.id = o.equipment_id group by e.id")
    List<Map<String,Object>> getEquipment();

    @Select("select count(id) customerNumber, (select count(*) from orders) orderNumber, (select count(*) from equipment) equipmentNumber from customer")
    Map<String, Object> getDetail();
}
